
setTimeout(function(){
	$("#dictionaryName").val('');
	//$("#dictionaryName").focus();
	$("#dictionaryName").rules("add",{
		remote: {
			url: 'sys/dic/checkName'+($("#dictionaryName").val()+""),
			type: "get",
			dataType: "json", 
			dataFilter:function(data,type){
				return data=="false"?false:true;
			
			}
		}, 
		messages: {remote: "该字典名称已添加"}
	});  
} , parseInt(Math.random() * 1000));


setTimeout(function(){
	//$("#dictionaryCode").focus();
	$("#dictionaryCode").rules("add",{
		remote: {
			url: 'sys/dic/checkCode'+($("#dictionaryCode").val()+""),
			type: "get",
			dataType: "json", 
			dataFilter:function(data,type){
				return data=="false"?false:true;
			
			}
		}, 
		messages: {remote: "该字典编码已存在"}
	});  
} , parseInt(Math.random() * 1000));



var app = angular.module('dictionaryApp', []);


app.controller('dictionaryController', function($scope, $http) {
	$scope.dictionary;
	
	$scope.refreshData=function(){
		$scope.dictionary={};
	}
	
	$scope.dictionarySave=function(){
	   if($("#myForm").valid()){
		   $http.post('sys/dic/add/', $scope.dictionary).success(function(){
               redirectUrl("manage/dictionary/","list.jsp");
           });
	   }
	}
	
	$scope.dictionaryReset=function(){
		$scope.dictionary={};
	}
	
	$scope.dictionaryCancle=function(){
		redirectUrl("manage/dictionary/","list.jsp");
	}


});